#!/usr/bin/perl

use strict;


# use $ for scalar variables and use @ for arrays

__END__
#Grepping in perl
my @data = ('joshua@profitera.com',"joshua\@gmail.com","higgs\@gmail.com");
my @filtereddata = grep(/gmail/,@data);
print ("@filtereddata\n");

__END__
my @data = ("This","is","my","string","array");
my $var = join("_",@data);
print "$var";

__END__
#Regex split
my $str = "This is my string";
my @result = split(/\s+/,$str);
print("@result\n") ;


__END__
#Regular expressions matching
my $var = "JIRA Version = 887, JAVA 1.7";
if($var =~ m/JIRA Version = (\d+), JAVA (\d+\.\d+)/)
{
	print("$1,$2\n");
}

__END__
my @darr = ();
push(@darr,"Tamela");
push(@darr,"Illibagiza");
push(@darr,("paulWall","PushaT"));

#loop an array to reveal it's contents
foreach(@darr){
	print("$_\n");
}

__END__
print($#darr); #get the size of the array

__END__
print(keys(%ENV));

__END__
my @darr = ();
push(@darr,"Tamela");
push(@darr,"Illibagiza");
push(@darr,("paulWall","PushaT"));

print("Full array = @darr\n");
print("Length of array = " . scalar(@darr) . "\n");

#push add items to an array
#shift removes items from the beginning of an array
#pop removes items from the end of an array
my $elem0 = shift(@darr);
print("Element 0 = $elem0\n");
print("@darr\n");

my $elem1 = shift(@darr);
print("Element 1 = $elem1\n");
print("@darr\n");

my $elem2 = shift(@darr);
print("Element 2 = $elem2\n");
print("@darr\n");


__END__
my @myarray = ("Chris","Paul");
my @secfarr = ();
$secfarr[0] = "Mike";
print("$myarray[0],$secfarr[0]\n");

__END__
my $flag = 1;
my $flag2 = 0;

print("Dave jumped the gun\n") if ($flag == 1);

__END__
if ((1 == $flag) || (3 == $flag2)) {
	# body...
} elsif () {
	# elsif...
} else {
	# else...
}


__END__
my $str1 = "ME";
my $str2 = "YOU";

